/**
 * Used to configure the global error handling function, which can monitor vue errors, script errors, static resource errors and Promise errors
 */

import {useLogsStore} from "../../store/modules/logs.js";


/**
 * Configure global error handling
 * @param app
 */
export function setupErrorHandle(app) {
  app.config.errorHandler = (err, instance, info) => {
    const logsStore = useLogsStore()
    // todo whf 目前关闭日志记录
    // logsStore.ADD_LOGS({
    //   type: 'error',
    //   message: err.message,
    //   stack: err.stack,
    //   info
    // })
    if (process.env.NODE_ENV === 'development') {
      console.group('>>>>>> 错误信息 >>>>>>')
      console.log(info)
      console.groupEnd();
      console.group('>>>>>> Vue 实例 >>>>>>')
      console.log(instance)
      console.groupEnd();
      console.group('>>>>>> Error信息 >>>>>>')
      console.log(err)
      console.groupEnd();
    }
  }
}
